import foard.model.EntryModel;
import foard.model.ThreadModel;
import foard.model.BoardModel;
import foard.model.BoardList;
import mx.events.ListEvent;
import spark.events.IndexChangeEvent;

public var boardList:BoardList;
public var boardModel:BoardModel;
public var threadModel:ThreadModel;
public var entryModel:EntryModel;

private var list1:List;
private var list2:List;
private var list3:List;

private function creationCompleteHandler():void
{
	list1 = i_list1;
	list2 = i_list2;
	list3 = i_list3;

	boardList = new BoardList();
	list1.dataProvider = boardList;
	list1.addEventListener(IndexChangeEvent.CHANGE, boardItemClickHandler);
	
	boardModel = new BoardModel("<A HREF=http://pc11.2ch.net/mac/>mac</A>");
	boardModel.load();
	list2.dataProvider = boardModel;
	list2.addEventListener(IndexChangeEvent.CHANGE, threadItemClickHandler);
	
	list3.addEventListener(IndexChangeEvent.CHANGE, entryItemClickHandler);
}

private function boardItemClickHandler(e:IndexChangeEvent):void
{
	boardModel = e.target.selectedItem as BoardModel;
	boardModel.load();
	
	list2.dataProvider = boardModel;
}

private function threadItemClickHandler(e:IndexChangeEvent):void
{
	threadModel = e.target.selectedItem as ThreadModel;
	threadModel.load();
	
	list3.dataProvider = threadModel;
}

private function entryItemClickHandler(e:IndexChangeEvent):void
{
	entryModel = e.target.selectedItem as EntryModel;
	
	trace(entryModel.body);
}